<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>选手列表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/${BasePath}/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/${BasePath}/static/css/public.css" media="all" type="text/css">
	<style>
		.layui-table-cell{
			height:50px;
			line-height:50px
		}
	</style>
</head>
<body class="childrenBody">
<form class="layui-form" lay-filter="example">
    <blockquote class="layui-elem-quote quoteBox">
			<div class="layui-inline">
			    <a class="layui-btn layui-btn-normal refresh">刷新</a>
				<a class="layui-btn layui-btn-normal addPlayer">添加选手</a>
				<a class="layui-btn layui-btn-normal" href="javascript:history.go(-1)">返回活动列表</a>
			</div>
	</blockquote> 
	<div id="photos">
		<table id="activityList" lay-filter="activityList"></table>
	</div>
</form>

	<!--操作-->
	<script type="text/html" id="playerListBar">
		<a class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
		{{#  if(d.sts=="Y"){ }}
			<a class="layui-btn layui-btn-xs" lay-event="end">冻结</a>
		{{#  } }}
        {{#  if(d.sts=="D"){ }}
			<a class="layui-btn layui-btn-xs" lay-event="sta">开启</a>
		{{#  } }}
        
        <a class="layui-btn layui-btn-xs" lay-event="add">加票</a>
		<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
	</script>
	<script type="text/html" id="sts">
    {{#  if(d.sts =="D"){ }}
       	冻结
    {{#  } }}
    {{#  if(d.sts =="Y"){ }}
                    正常
    {{#  } }}
	</script>
<script src="/${BasePath}/static/layui/layui.js" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript" src="/${BasePath}/static/js/common/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="/${BasePath}/static/js/common/datatable_common.js"></script>
<script type="text/javascript">
layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = layui.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;

    //列表
    var tableIns = table.render({
        elem: '#activityList',
        url : '/${BasePath}/activity/queryPlayerPage?activityid=${activityid!''}',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limit : 40,
        limits : [40,50,60,70,80],
        id : "productsListTable",
        cols : [[
            {type: "checkbox", fixed:"left", width:50},
           /*  {field: 'id', title: '序号', width:100}, */
            {field: 'playerno', title: '编号', width:100},
            {field: 'name', title: '昵称', width:250},
            {field: 'amount', title: '金额', width:100},
            {field: 'poll', title: '获得票数', width:150},
            {field: 'declaration', title: '宣言', width:350},
            {field: 'tel', title: '电话', width:250},
            {field: 'tel', title: '状态', width:250,templet: '#sts'},
            {title: '操作', templet:'#playerListBar',fixed:"right", width:250,align:"center"}
        ]],
        done: function () {
            layer.photos({
                photos: '#photos'
            });
        },
    skin: 'line'
    });

    function editActivity(edit){
    	window.location.href="/${BasePath}/activity/addPlayer?activityid=${activityid!''}&id="+edit.id;
    }
    function queryActivityPlayer(query){
 	    window.location.href="/${BasePath}/activity/playerList?id="+query.id;
    }
    $(".addPlayer").click(function(){
    	window.location.href="/${BasePath}/activity/addPlayer?activityid=${activityid!''}";
    })
    $(".refresh").click(function(){
    	window.location.reload();
    })

    //列表操作
    table.on('tool(activityList)', function(obj){
        var layEvent = obj.event,
            data = obj.data;

        if(layEvent === 'edit'){ //编辑
        	editActivity(data);
        } else if(layEvent === 'del'){ //删除
        	layer.confirm('确定要删除该选手？',{icon:3, title:'提示信息'},function(index){
                $.get("/${BasePath}/activity/saveOrUpdatePlayer",{
                    id : data.id,sts :"N"
                },function(data){
                   tableIns.reload();
                   layer.close(index);
                })
           });
        } else if(layEvent === 'query'){
        	queryActivityPlayer(data);
        }else if(layEvent === 'end'){
        	layer.confirm('确定要冻结该选手投票通道？',{icon:3, title:'提示信息'},function(index){
                $.get("/${BasePath}/activity/saveOrUpdatePlayer",{
                    id : data.id,sts :"D"
                },function(data){
                   tableIns.reload();
                   layer.close(index);
                })
           });
        }else if(layEvent === 'sta'){
        	layer.confirm('确定要开启该选手投票通道？',{icon:3, title:'提示信息'},function(index){
                $.get("/${BasePath}/activity/saveOrUpdatePlayer",{
                    id : data.id,sts :"Y"
                },function(data){
                   tableIns.reload();
                   layer.close(index);
                })
           });
        }else if(layEvent === 'add'){
        	layer.open({
        		  type: 2,
        		  title: '加票',
        		  shade: [0],
        		  area: ['600px', '400px'],
        		  anim: 2,
        		  content: ['/${BasePath}/activity/addTicket?id='+data.id], //iframe的url，no代表不显示滚动条
        		  
        		});
        }
    });

})
</script>
</body>
</html>